﻿using MN.Framework.Common.Security;
using MN.Framework.UI.Win.Forms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI.Localization;

namespace MN.Framework.UI.Win
{
    public class MnApplication
    {
        public static MnBaseForm Start(IAuthentication authenticationClass, MnBaseForm mainForm)
        {
            return Start(authenticationClass, mainForm, null);
        }
        public static MnBaseForm Start(IAuthentication authenticationClass, MnBaseForm mainForm, MnBaseForm loginForm)
        {            
            RadMessageLocalizationProvider.CurrentProvider = new MnRadMessageLocalizationProvider();
            RadGridLocalizationProvider.CurrentProvider = new MnPersianRadGridLocalizationProvider();

            if (authenticationClass != null)
            {
                if (loginForm != null)
                    return loginForm;
                else
                    return new LoginForm(authenticationClass, mainForm);
            }
            else
            {
                return mainForm;
            }

        }
        public static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            RadMessageBox.Show(e.Exception.Message, "خطا رخ داد", MessageBoxButtons.OK, RadMessageIcon.Error);
        }
    }
}
